package com.xidian.zhiancloud.controller.ypp.messageCenter.untreated;

import com.github.pagehelper.Page;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.Information;
import com.xidian.zhiancloud.model.Notice;
import com.xidian.zhiancloud.model.Untreated;
import com.xidian.zhiancloud.service.ypp.messageCenter.untreated.UntreatedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 待办
 */
@RestController
@RequestMapping("/untreated")
public class UntreatedController {
    @Autowired
    private UntreatedService untreatedService;

//    @GetMapping("/getById/{status}")
//    public ResultDTO getById(
//            @PathVariable("status") String status) {
//        return ResultDTO.successOf(untreatedService.getById(status), GeneralResponseEnums.SUCCESS);
//    }

//    @PutMapping("/updateById")
//    public ResultDTO updateById(List<Untreated> untreatedList){
//        untreatedService.updateByIds(untreatedList);
//        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
//    }


    //查看详细内容
    @GetMapping("/getUntreatedById")
    public ResultDTO getUntreatedById(
            @RequestParam("id") Long id) {
        return ResultDTO.successOf(untreatedService.getInformation(id), GeneralResponseEnums.SUCCESS);
    }
    
    //根据条件查询
    @GetMapping("/getList")
    public ResultDTO list( Untreated info)
    {
    	Page<Untreated> pagedata = untreatedService.getUntreatedList(info);
		
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("datalist", pagedata);
		data.put("PageNum", pagedata.getPageNum());
		data.put("PageSize", pagedata.getPageSize());
		data.put("PageTotal", pagedata.getPages());
		data.put("total", pagedata.getTotal());
		return ResultDTO.successOf(data,GeneralResponseEnums.SUCCESS);
    }
    
    //增加
    @PostMapping("/add")
    public ResultDTO add(@RequestBody Notice info)
    {
    	untreatedService.insertInfo(info);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
    
    //批量标记
    @GetMapping("/update")
    public ResultDTO update( @RequestParam("ids") Long[] ids)
    {
    	untreatedService.updateUntreatedByIds(ids);
    	return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
    
}
